<template >
  <div class="container">
    <el-menu
      :uniqueOpened="true"
      :default-active="thisPath"
      class="el-menu-vertical-demo"
      :unique-opened="true"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
      :router="true"
    >
      <el-submenu index="1">
        <template #title>
          <i class="el-icon-location"></i>
          <span>用户管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/home/userlist">用户列表</el-menu-item>
          <el-menu-item index="/home/userinfo">个人信息</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="2">
        <template #title>
          <i class="el-icon-location"></i>
          <span>vuex</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/home/checkvuexpages">checkvuexpages</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-menu-item index="3">
        <i class="el-icon-document"></i>
        <template #title>导航三</template>
      </el-menu-item>
      <el-menu-item index="4">
        <i class="el-icon-setting"></i>
        <template #title>导航四</template>
      </el-menu-item>
    </el-menu>
  </div>
</template>
<script>
import { defineComponent, ref, onMounted, watch } from "vue";
import { useRoute } from "vue-router";
export default defineComponent({
  setup() {
    let thisPath = ref("");
    let Route = useRoute();
    onMounted(() => {
      thisPath.value = Route.path;
    });
    watch(()=>Route.path, n => {
      thisPath.value = n;
    });
    return {
      thisPath
    };
  }
});
</script>
<style lang="less" scoped>
.container {
  width: 100%;
  height: 100%;
  .el-menu-vertical-demo {
    height: 100%;
  }
}
</style>